﻿//using PetaPoco;
using NPoco;
using PocoConsole.PetaPoco;
using System;
using System.Collections.Generic;

namespace PocoConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            #region PetaPoco
            //var db = new Database("postgres");

            //var person = new Person { Id = Guid.NewGuid(), Name = "PetaPoco", Dob = new DateTime(2011, 1, 1), Age = (DateTime.Now.Year - 2011), Height = 242 };

            //// Tell PetaPoco to insert it
            //var id = db.Insert(person);

            //foreach(var a in db.Query<Person>("SELECT * FROM \"People\""))
            //{
            //    Console.WriteLine($"{a.Id} - {a.Name}");
            //}
            #endregion

            #region npoco
            //IDatabase db = new Database("postgres");
            //var persons = db.Query<Person>().Where(x => x.Name == "PetaPoco")
            //                           .OrderBy(x => x.Id)
            //                           .Limit(1, 10)
            //                           .ToList();


            #endregion

            var _dynamicObjectList = new List<Student>();
            for (int i = 0; i < 5; i++)
            {
                _dynamicObjectList.Add(new Student { ID = i, Name = "stu" + i, Address = "address" + i, AdmissionDate = DateTime.Now.AddDays(i), Age = 15, FatherName = "Jamal" + i, MotherName = "Jamila" + i });
            }
            //create again for checking distinct list
            for (int i = 0; i < 5; i++)
            {
                _dynamicObjectList.Add(new Student { ID = i, Name = "stu" + i, Address = "address" + i, AdmissionDate = DateTime.Now.AddDays(i), Age = 15, FatherName = "Jamal" + i, MotherName = "Jamila" + i });
            }



            //   var returnList = test2.GetDdlData<Object>(_dynamicObjectList, "ID,Name,Address");
            //   var returnList = test2.GetDdlData<Object>(_dynamicObjectList, "ID,FatherName,Address");
            var returnList = test2.GetDdlData<Object>(_dynamicObjectList, "ID,Name,FatherName,MotherName,Age");

            //string strSerializeData = JsonConvert.SerializeObject(returnList);
            //Console.WriteLine(strSerializeData);
            Console.ReadLine();


        }
    }
}
